package com.hrt.web.mailRecord.service.impl;

import java.sql.Timestamp;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.hrt.bean.MailRecord;
import com.hrt.util.MailUtil;
import com.hrt.web.mailRecord.dao.MailRecordDao;
import com.hrt.web.mailRecord.service.MailRecordService;

@Transactional
@Service
public class MailRecordServiceImpl implements MailRecordService{
	@Autowired
	private MailRecordDao mailRecordDao;
	@Override
	public void saveMailRecord(MailRecord mailRecord) throws Exception {
		mailRecordDao.saveEntity(mailRecord);
		
	}

	@Override
	public Timestamp getDate() {
		return mailRecordDao.getDate();
	}

	@Override
	public MailRecord getCodeByMail(String mail) {
		return mailRecordDao.getCodeByMail(mail);
	}


	@Override
	public void sendMail(String toMail, String jym) {
		MailUtil sendmail = new MailUtil();
		//设置邮箱服务器,当前位163邮箱服务器
		sendmail.setHost("smtp.163.com");
		//发件人姓名，与邮箱可一致
		sendmail.setUserName("lisiyuan_job@163.com");
		//发件人邮箱密码
		sendmail.setPassWord("a1994520");
		//收件人邮箱地址
		sendmail.setTo(toMail);
		//发件人邮箱地址
		sendmail.setFrom("lisiyuan_job@163.com");
		//邮件主题
		sendmail.setSubject("何人堂网站注册验证");
		//邮件内容
		sendmail.setContent("您此次修改邮箱的验证码是"+jym);
		sendmail.sendMail();
		
	}

	@Override
	public void updateMailRecord(MailRecord mailRecord) throws Exception {
		mailRecordDao.updateEntity(mailRecord);
		
	}

}
